/* const db = uniCloud.database()
get:async function(e){
	let res = db.collection(e).get()
	let result = {
		error:0,
		errMsg:"查询成功",
		data:res.data
	}
	return result
} */

function giveMsg(str){
	let msgObj={
		"success":"查询成功",
		"noSuccess":"查询失败",
		"add":"新增成功",
		"noAdd":"新增失败",
		"required":"须要参数"
	}
	return msgObj[str]
}

function giveCode(num){
	let codeObj={
		0:0,
		200:200,//成功的返回码
		400:400		//失败的返回码
	}
	return codeObj[num]
}

/* class useResult{
	constructor(errCode,errMsg,data){
		this.errCode=giveCode(errCode)
		this.errMsg=giveMsg(errMsg)
		this.data=data
	}
} */

function result(errCode,errMsg,data){
	return {
		message:data,
		meta:{
			msg:giveMsg(errMsg),
			status:giveCode(errCode),
		}
	}
}

module.exports =  {
	giveMsg,
	giveCode,
	result
}
